@m75 said in Swapping between HDMI and CRT sound+image issues.:
So going back to HDMI I'd have to remove/comment audio_pwm_mode=0
You can quickly toggle the option from a script or the console by these commands:
# make a backup of config.txt
cp /boot/config.txt /boot/config.txt.backup
# switch to "1"
sed -i -e 's/audio_pwm_mode=0/audio_pwm_mode=1/g' /boot/config.txt
# switch to "0"
sed -i -e 's/audio_pwm_mode=1/audio_pwm_mode=0/g' /boot/config.txt
The lines beginning with # are comments and can be omitted. Mind the single quotation marks, they're important!
You could save them in convenient executable scripts in a (new) directory called "bin" in your home directory:
cd /home/pi # make sure we are at home
mkdir bin # create the directory "bin"
echo "sed -i -e 's/audio_pwm_mode=0/audio_pwm_mode=1/g' /boot/config.txt" > bin/pwm1 # write the first sed command to bin/pwm1
echo "sed -i -e 's/audio_pwm_mode=1/audio_pwm_mode=0/g' /boot/config.txt" > bin/pwm0 # write the second sed command to bin/pwm0
chmod u+x bin/pwm1 # make pwn1 executable
chmod u+x bin/pwm0 # make pwn0 executable
Since $HOME/bin is part of the console's search paths for commands and scripts, you can now just execute pwm1 or pwm0from any directory to toggle the option audio_pwm_mode between 1 an 0.
Besides that matter, do you know that you can enable an experimental audio driver with audio_pwm_mode=2? It fixed an annoying static noice on my Pi.